home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Found / FWString / Include / FWStrs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-21  |  23.2 KB  |  726 lines  |  [TEXT/MPS ]

  1. #ifndef FWSTRS_H
  2. #define FWSTRS_H
  3. //========================================================================================
  4. //
  5. //    File:                FWStrs.h
  6. //    Release Version:    $ 1.0d1 $
  7. //
  8. //    Creation Date:        3/28/94
  9. //
  10. //    Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  11. //
  12. //========================================================================================
  13.  
  14. #ifndef FWSTDDEF_H
  15. #include "FWStdDef.h"
  16. #endif
  17.  
  18. #ifndef FWEXCDEF_H
  19. #include "FWExcDef.h"
  20. #endif
  21.  
  22. #ifndef FWCHARIT_H
  23. #include "FWCharIt.h"
  24. #endif
  25.  
  26. #ifndef FWCHARAC_H
  27. #include "FWCharac.h"
  28. #endif
  29.  
  30. //========================================================================================
  31. // Forward Declarations
  32. //========================================================================================
  33.  
  34. class FW_CStringReader;
  35. class FW_CStringWriter;
  36. class FW_CStringTool;
  37. class FW_CStringArchiver;
  38.  
  39. //========================================================================================
  40. //    CLASS FW_CString
  41. //
  42. //    String class implementations must satisfy the following requirements:
  43. //
  44. //    1) The string representation is kept in memory.
  45. //    2) The string representation is contiguous.
  46. //    3) The string is NUL-terminated.
  47. //
  48. //    Characters in strings may occupy one, two, and possibly more bytes.
  49. //  The number of characters in the string is therefore not necessarily 
  50. //    equal to the number of bytes in the string.
  51. //
  52. //    Since characters may be variable size, there is no general way to directly access a 
  53. //    character given it's position.  Thus, it is crucial to use iterators to access the
  54. //    contents of a string such that position state information can be maintained.
  55. //
  56. //    The "length" of the string is measured in characters.
  57. //  The "byteLength" of the string is measured in bytes.
  58. //  The "capacity" of the string is measure in bytes.
  59. //
  60. //========================================================================================
  61.  
  62. class FW_CString : public _FW_CAutoDestructObject
  63. {
  64. public:
  65.  
  66.     friend class FW_CStringReader;
  67.     friend class FW_CStringWriter;
  68.     friend class FW_CStringTool;
  69.     friend class FW_CStringArchiver;
  70.  
  71.     FW_DECLARE_CLASS
  72.     
  73.     ~FW_CString();
  74.     FW_CString();    
  75.     FW_CString(const FW_CString &string);    
  76.  
  77.     FW_CString& operator=(const FW_CString& string);
  78.     FW_CString& operator=(const FW_Char* string);
  79.     
  80.     FW_CharacterCount GetLength() const;
  81.  
  82.     FW_ByteCount GetByteLength() const;
  83.  
  84.     FW_ByteCount GetCapacity() const;
  85.  
  86.     operator const FW_Char*() const;
  87.         // Return a pointer to the first character in the string.
  88.         // Strings must be contiguous storage, and NUL-terminated!
  89.     
  90.     virtual FW_ByteCount GrowCapacity(FW_ByteCount capacityNeeded) = 0;
  91.         // Expand the string, if necessary to capacityNeeded.
  92.         // Return the new capacity of the string, which may be less than capacityNeeded!
  93.         // The capacity of a string is never reduced (except by deleting the string).
  94.  
  95.     FW_Char operator[](FW_CharacterPosition position) const;
  96.         // Retrieve character at given position.
  97.         // Cannot be used on LHS of assignment.
  98.         // The NUL-terminator at position=fLength cannot be accessed.
  99.         
  100.     void Retrieve(FW_Char* items, 
  101.                     FW_CharacterCount numberItems, 
  102.                     FW_CharacterPosition position) const;
  103.         // Retrieve numberItems of characters starting at position.
  104.         
  105.     void Delete(FW_CharacterCount numberItems, 
  106.                         FW_CharacterPosition position);
  107.         // Delete numberItems characters, starting at position.
  108.         
  109.     void Replace(const FW_Char* items, 
  110.                         FW_CharacterCount numberItems, 
  111.                         FW_CharacterPosition position);
  112.         // Replace numberItems of items starting at position.
  113.         
  114.     void Insert(const FW_Char* items, 
  115.                 FW_CharacterCount numberItems,  
  116.                 FW_CharacterPosition position);
  117.         // Insert characters into string just before the character at positition.
  118.         // Insert at position GetLength() appends the characters.
  119.         // Insert at position 0 prepends the characters.
  120.     
  121.     void Insert(const FW_CString &string, FW_CharacterPosition position);
  122.         // Insert string at position.
  123.     
  124.     void Export(char* buffer) const;
  125.         // Copy contents of this string to external buffer.
  126.         // buffer will contain nul-terminated string.
  127.         // It is client's responsibilitiy to ensure buffer is large enough.
  128.     
  129.     void ReplaceAll(const FW_CString &string);
  130.         // Replace entire contents of this string with string.
  131.     
  132.     void ReplaceAll(const FW_Char* items, FW_CharacterCount numberItems);
  133.         // Replace entire contents of this string with items.
  134.  
  135.     void ReplaceAll(const FW_Char* string);
  136.         // Replace entire contents of this string with (nul-terminated) string.
  137.     
  138.     void Append(const FW_CString &string);
  139.         // Append string onto end of this string.
  140.     
  141.     void Append(const FW_Char* items, FW_CharacterCount numberItems);
  142.         // Append items onto end of this string.
  143.     
  144.     void Append(const FW_Char* string);
  145.         // Append (nul-terminated) string onto end of this string.
  146.     
  147.     void Append(FW_Char character);
  148.         // Append a single character onto the end of this string.
  149.     
  150.     void Prepend(const FW_Char* items, FW_CharacterCount numberItems);
  151.         // Prepend items onto beginning of this string.
  152.         
  153.     void Prepend(const FW_CString &string);
  154.         // Prepend string onto beginning of this string.
  155.     
  156.     void Truncate(FW_CharacterPosition position);
  157.         // Truncate string at position.  Truncate(0) clears string.
  158.         
  159.     FW_CString& operator+=(const FW_CString &string);
  160.         // Append string onto the end of this string.
  161.         
  162.     FW_CString& operator+=(const FW_Char* items);
  163.         // Append (nul-terminated) items onto the end of this string.
  164.         
  165.     FW_CString& operator+=(FW_Char character);
  166.         // Append a single character onto the end of this string.
  167.         
  168.     // ----- StringTool functions, passed through to current StringTool
  169.     //       These functions are convenience functions only, and will
  170.     //         work correctly only if both strings are of the same locale.
  171.     
  172.     void ToUpper();
  173.     void ToLower();
  174.  
  175.     FW_Boolean Substitute(const FW_CString &searchString,
  176.                         const FW_CString &substitutionString);
  177.     
  178.     FW_Boolean FindSubString(const FW_CString &subString,
  179.                              FW_CharacterPosition &foundPosition,
  180.                              FW_CharacterPosition startPosition=0) const;
  181.     
  182.     FW_Boolean FindCharacter(FW_Char character,
  183.                              FW_CharacterPosition &foundPosition,
  184.                              FW_CharacterPosition startPosition=0) const;
  185.     
  186.     FW_Boolean FindWhiteSpace(FW_CharacterPosition &foundPosition,
  187.                             FW_CharacterPosition startPosition=0) const;
  188.                                          
  189.     FW_Boolean FindNonWhiteSpace(FW_CharacterPosition &foundPosition,
  190.                                 FW_CharacterPosition startPosition=0) const;
  191.                                          
  192.     FW_Boolean operator==(const FW_CString &string) const;
  193.     FW_Boolean operator!=(const FW_CString &string) const;
  194.     FW_Boolean operator<(const FW_CString &string) const;
  195.     FW_Boolean operator>(const FW_CString &string) const;
  196.     FW_Boolean operator<=(const FW_CString &string) const;
  197.     FW_Boolean operator>=(const FW_CString &string) const;
  198.  
  199. #ifdef FW_BUILD_MAC
  200. public:
  201.  
  202.     // ----- 'Pascal' strings for Macintosh toolbox
  203.  
  204.     void ExportPascal(FW_PascalChar* buffer) const;
  205.         // Copy contents of this string to external 'pascal' buffer.
  206.         // buffer will contain pascal string string with length byte at buffer[0].
  207.         // It is client's responsibilitiy to ensure buffer is large enough.
  208.  
  209.     void ReplaceAll(const FW_PascalChar* string);
  210.         // Replace entire contents of this string with pascal string.
  211. #endif
  212.  
  213. protected:
  214.  
  215.     void SetLength(FW_CharacterCount characters, FW_ByteCount bytes);
  216.     
  217.     FW_Byte* fRepresentation;
  218.         
  219.     FW_CharacterCount    fLength;
  220.         // Cached length.
  221.         // Must always be kept up to date, since GetLength is nonvirtual inline.
  222.  
  223. #ifdef  FW_VARIABLE_WIDTH_CHARACTERS
  224.     FW_ByteCount    fByteLength;
  225.         // Cached length in bytes.
  226.         // Must always be kept up to date, since GetByteLength is nonvirtual inline.
  227. #endif
  228.  
  229.     FW_ByteCount    fCapacity;
  230.         // Cached capacity.
  231.         // Must always be kept up to date, since GetCapacity is nonvirtual inline.
  232.  
  233. private:
  234.  
  235.     int Compare(const FW_CString &string) const;
  236.         // An implementation method.  Clients use comparision operators.
  237.         
  238. };
  239.  
  240. //========================================================================================
  241. //    CLASS FW_TBoundedString
  242. //========================================================================================
  243.  
  244. template <int tCapacity>
  245. class FW_TBoundedString : public FW_CString
  246. {
  247. public:
  248.  
  249.     FW_DECLARE_CLASS
  250.     
  251.     ~FW_TBoundedString();
  252.     FW_TBoundedString();
  253.     FW_TBoundedString(const FW_TBoundedString<tCapacity> &string);
  254.     FW_TBoundedString(const FW_CString &string);
  255.     FW_TBoundedString(const FW_Char *items, FW_CharacterCount numberItems);
  256.     FW_TBoundedString(const FW_Char *items);
  257.     
  258.     FW_CString& operator=(const FW_TBoundedString<tCapacity> &string);
  259.     FW_CString& operator=(const FW_CString& string);
  260.     FW_CString& operator=(const FW_Char* string);
  261.     
  262.     virtual FW_ByteCount GrowCapacity(FW_ByteCount capacityNeeded);
  263.         // Return tCapacity*FW_kMedianCharacterSize.  The capacity of bounded strings never changes.
  264.  
  265. private:
  266.  
  267.     FW_Byte            fStorage[tCapacity*FW_kMedianCharacterSize+sizeof(FW_Char)];
  268.         // Must leave room for a NUL word
  269. };
  270.  
  271. typedef FW_TBoundedString<32> FW_CString32;
  272. typedef FW_TBoundedString<255> FW_CString255;
  273.  
  274. //========================================================================================
  275. //    CLASS FW_CDynamicString
  276. //========================================================================================
  277.  
  278. class FW_CDynamicString : public FW_CString
  279. {
  280. public:
  281.  
  282.     FW_DECLARE_CLASS
  283.     
  284.     ~FW_CDynamicString();
  285.     FW_CDynamicString(FW_ByteCount capacity=0);
  286.     FW_CDynamicString(const FW_CDynamicString &string);
  287.     FW_CDynamicString(const FW_CString &string);
  288.     FW_CDynamicString(const FW_Char *items, FW_CharacterCount numberItems);
  289.     FW_CDynamicString(const FW_Char *items);
  290.  
  291.     FW_CString& operator=(const FW_CDynamicString &string);
  292.     FW_CString& operator=(const FW_CString& string);
  293.     FW_CString& operator=(const FW_Char* string);
  294.     
  295.     virtual FW_ByteCount GrowCapacity(FW_ByteCount capacityNeeded);
  296.         // Expand the string, if necessary to capacityNeeded.
  297.         // Return the new capacity of the string.
  298.         // The capacity of a string is never reduced (except by deleting the string).
  299.         
  300. protected:
  301.  
  302.     void Resize(FW_ByteCount newCapacity);
  303.  
  304. private:
  305.  
  306.     void AllocateRepresentation(FW_ByteCount capacity);
  307. };
  308.  
  309. //========================================================================================
  310. //    CLASS FW_CStringReader
  311. //========================================================================================
  312.  
  313. class FW_CStringReader : public FW_CTextReader
  314. {
  315. public:
  316.     FW_CStringReader(const FW_CString &string);
  317.     FW_CStringReader(const FW_CString &string,
  318.                                 FW_CharacterPosition start,
  319.                                 FW_CharacterCount   length);
  320.  
  321. protected:
  322.  
  323.     virtual void DoGetNextBuffer();
  324.         // Get another buffer from text data structure.
  325.         // Updates fStart and fLimit.
  326.         // Must ensure that fStart<=fLimit
  327.  
  328.     virtual void DoGetPreviousBuffer();
  329.         // Gets previous buffer from text data structure.
  330.         // Updates fStart and fLimit.
  331.         // Must ensure that fStart<=fLimit
  332.     
  333. };
  334.  
  335. //========================================================================================
  336. //    CLASS FW_CStringWriter
  337. //========================================================================================
  338.  
  339. class FW_CStringWriter : public FW_CTextWriter
  340. {
  341. public:
  342.     enum {kDefaultExpansion=32};
  343.  
  344.     ~FW_CStringWriter();
  345.     FW_CStringWriter(FW_CString &string, 
  346.                      FW_TextWriterMode mode=FW_kTextAppend,
  347.                      unsigned short expansion=kDefaultExpansion);
  348.  
  349. protected:
  350.  
  351.     virtual void DoFlushAndGetNextBuffer();
  352.         // Flush the current buffer.
  353.         // Get another buffer from string, update fNext and fLimit.
  354.  
  355.     void FlushAndUpdateText();
  356.         // Flush the current buffer.
  357.         // Do whatever may be necessary to restore text structure to valid state,
  358.         // ... e.g. restore NUL termination, cached length member, etc.
  359.         // This method is called from destructor.
  360.  
  361.     FW_CString    &fString;
  362.     unsigned short fExpansion;
  363.     FW_Byte *fBuffer;
  364. };
  365.  
  366. //========================================================================================
  367. //    CLASS FW_CString
  368. //========================================================================================
  369.  
  370. //----------------------------------------------------------------------------------------
  371. //    FW_CString::GetLength
  372. //----------------------------------------------------------------------------------------
  373.  
  374. inline FW_CharacterCount FW_CString::GetLength() const
  375. {
  376.     return fLength;
  377. }
  378.  
  379. //----------------------------------------------------------------------------------------
  380. //    FW_CString::GetByteLength
  381. //----------------------------------------------------------------------------------------
  382.  
  383. inline FW_ByteCount FW_CString::GetByteLength() const
  384. {
  385. #ifdef  FW_VARIABLE_WIDTH_CHARACTERS
  386.     return fByteLength;
  387. #else
  388.     return fLength*sizeof(FW_Char);
  389. #endif
  390. }
  391.  
  392. //----------------------------------------------------------------------------------------
  393. //    FW_CString::GetCapacity
  394. //----------------------------------------------------------------------------------------
  395.  
  396. inline FW_ByteCount FW_CString::GetCapacity() const
  397. {
  398.     return fCapacity;
  399. }
  400.  
  401. //----------------------------------------------------------------------------------------
  402. //    FW_CString::SetLength
  403. //----------------------------------------------------------------------------------------
  404.  
  405. inline void FW_CString::SetLength(FW_CharacterCount characters, FW_ByteCount bytes)
  406. {
  407.     fLength = characters;
  408. #ifdef  FW_VARIABLE_WIDTH_CHARACTERS
  409.     fByteLength = bytes;
  410.     for (i=0; i< sizeof(FW_Char); i++)
  411.     {
  412.         // set 1 byte at a time because some machines (e.g. MC68010) may not allow 
  413.         // writing words to odd addresses
  414.         fRepresentation[bytes+i] = 0;
  415.     }
  416. #else
  417.     FW_ASSERT(bytes == characters*sizeof(FW_Char));
  418.     *((FW_Char*)(fRepresentation+bytes)) = FW_kNulCharacter;
  419. #endif
  420. }
  421.  
  422. //----------------------------------------------------------------------------------------
  423. //    FW_CString::operator const FW_Char*
  424. //----------------------------------------------------------------------------------------
  425.  
  426. inline FW_CString::operator const FW_Char*() const
  427. {
  428.     return (const FW_Char*) fRepresentation;
  429. }
  430.  
  431. //----------------------------------------------------------------------------------------
  432. //    FW_CString::operator=
  433. //----------------------------------------------------------------------------------------
  434.  
  435. inline FW_CString& FW_CString::operator=(const FW_CString& string)
  436. {
  437.     if (&string != this)
  438.         ReplaceAll(string);
  439.     return *this;
  440. }
  441.  
  442. //----------------------------------------------------------------------------------------
  443. //    FW_CString::operator=
  444. //----------------------------------------------------------------------------------------
  445.  
  446. inline FW_CString& FW_CString::operator=(const FW_Char* string)
  447. {
  448.     ReplaceAll(string, FW_StringLength(string));
  449.     return *this;
  450. }
  451.  
  452. //----------------------------------------------------------------------------------------
  453. //    FW_CString::Export
  454. //----------------------------------------------------------------------------------------
  455.  
  456. inline void FW_CString::Export(FW_Char* buffer) const
  457. {
  458.     FW_BlockMove(fRepresentation, (FW_Byte*) buffer, GetByteLength()+sizeof(FW_Char));
  459. }
  460.  
  461. #ifdef FW_BUILD_MAC
  462. //----------------------------------------------------------------------------------------
  463. //    FW_CString::ExportPascal
  464. //----------------------------------------------------------------------------------------
  465.  
  466. inline void FW_CString::ExportPascal(FW_PascalChar* buffer) const
  467. {
  468.     FW_BlockMove(fRepresentation, (FW_Byte*)(buffer+1), fLength);
  469.     buffer[0] = (FW_PascalChar) fLength;
  470. }
  471. #endif
  472.  
  473. #ifdef FW_BUILD_MAC
  474. //----------------------------------------------------------------------------------------
  475. //    FW_CString::ReplaceAll
  476. //----------------------------------------------------------------------------------------
  477.  
  478. inline void FW_CString::ReplaceAll(const FW_PascalChar* items)
  479. {
  480.     ReplaceAll((FW_Char*) items+1, items[0]);
  481. }
  482. #endif
  483.  
  484. //----------------------------------------------------------------------------------------
  485. //    FW_CString::ReplaceAll
  486. //----------------------------------------------------------------------------------------
  487.  
  488. inline void FW_CString::ReplaceAll(const FW_CString& string)
  489. {
  490.     Replace((const FW_Char*)string, string.fLength, 0);
  491.     Truncate(string.fLength);
  492. }
  493.  
  494. //----------------------------------------------------------------------------------------
  495. //    FW_CString::ReplaceAll
  496. //----------------------------------------------------------------------------------------
  497.  
  498. inline void FW_CString::ReplaceAll(const FW_Char* items,
  499.                 FW_CharacterCount numberItems)
  500. {
  501.     Replace(items, numberItems, 0);
  502.     Truncate(numberItems);
  503. }
  504.  
  505. //----------------------------------------------------------------------------------------
  506. //    FW_CString::ReplaceAll
  507. //----------------------------------------------------------------------------------------
  508.  
  509. inline void FW_CString::ReplaceAll(const FW_Char* items)
  510. {
  511.     ReplaceAll(items, FW_StringLength(items));
  512. }
  513.  
  514. //----------------------------------------------------------------------------------------
  515. //    FW_CString::Insert
  516. //----------------------------------------------------------------------------------------
  517.  
  518. inline void FW_CString::Insert(const FW_CString& string,
  519.             FW_CharacterPosition position)
  520. {
  521.     Insert(string, string.fLength, position);
  522. }
  523.  
  524. //----------------------------------------------------------------------------------------
  525. //    FW_CString::Append
  526. //----------------------------------------------------------------------------------------
  527.  
  528. inline void FW_CString::Append(const FW_CString& string)
  529. {
  530.     Insert(string, string.fLength, fLength);
  531. }
  532.  
  533. //----------------------------------------------------------------------------------------
  534. //    FW_CString::Append
  535. //----------------------------------------------------------------------------------------
  536.  
  537. inline void FW_CString::Append(const FW_Char* items,
  538.             FW_CharacterCount numberItems)
  539. {
  540.     Insert(items, numberItems, fLength);
  541. }
  542.  
  543. //----------------------------------------------------------------------------------------
  544. //    FW_CString::Append
  545. //----------------------------------------------------------------------------------------
  546.  
  547. inline void FW_CString::Append(const FW_Char* string)
  548. {
  549.     Insert(string, FW_StringLength(string), fLength);
  550. }
  551.  
  552. //----------------------------------------------------------------------------------------
  553. //    FW_CString::Append
  554. //----------------------------------------------------------------------------------------
  555.  
  556. inline void FW_CString::Append(FW_Char character)
  557. {
  558.     Insert(&character, 1, fLength);
  559. }
  560.  
  561. //----------------------------------------------------------------------------------------
  562. //    FW_CString::Prepend
  563. //----------------------------------------------------------------------------------------
  564.  
  565. inline void FW_CString::Prepend(const FW_Char* items,
  566.              FW_CharacterCount numberItems)
  567. {
  568.     Insert(items, numberItems, 0);
  569. }
  570.  
  571.  
  572. //----------------------------------------------------------------------------------------
  573. //    FW_CString::Prepend
  574. //----------------------------------------------------------------------------------------
  575.  
  576. inline void FW_CString::Prepend(const FW_CString& string)
  577. {
  578.     Insert(string, string.fLength, 0);
  579. }
  580.  
  581.  
  582. //----------------------------------------------------------------------------------------
  583. //    FW_CString::Truncate
  584. //----------------------------------------------------------------------------------------
  585.  
  586. inline void FW_CString::Truncate(FW_CharacterPosition position)
  587. {
  588.     Delete(fLength - position, position);
  589. }
  590.  
  591.  
  592. //----------------------------------------------------------------------------------------
  593. //    FW_CString::operator+=
  594. //----------------------------------------------------------------------------------------
  595.  
  596. inline FW_CString& FW_CString::operator+=(const FW_CString& string)
  597. {
  598.     Append(string);
  599.     return *this;
  600. }
  601.  
  602. //----------------------------------------------------------------------------------------
  603. //    FW_CString::operator+=
  604. //----------------------------------------------------------------------------------------
  605.  
  606. inline FW_CString& FW_CString::operator+=(const FW_Char* string)
  607. {
  608.     Append(string);
  609.     return *this;
  610. }
  611.  
  612. //----------------------------------------------------------------------------------------
  613. //    FW_CString::operator+=
  614. //----------------------------------------------------------------------------------------
  615.  
  616. inline FW_CString& FW_CString::operator+=(FW_Char character)
  617. {
  618.     Append(character);
  619.     return *this;
  620. }
  621.  
  622. //----------------------------------------------------------------------------------------
  623. //    FW_CString::operator[]
  624. //----------------------------------------------------------------------------------------
  625.  
  626. inline FW_Char FW_CString::operator[](FW_CharacterPosition position) const
  627. {
  628. #ifdef  FW_VARIABLE_WIDTH_CHARACTERS
  629.     return NotYetImplemented();
  630. #else
  631.     return ((FW_Char*)fRepresentation)[position];
  632. #endif
  633. }
  634.  
  635. //========================================================================================
  636. //    CLASS FW_TBoundedString
  637. //========================================================================================
  638.  
  639. //----------------------------------------------------------------------------------------
  640. //    FW_TBoundedString<tCapacity>::operator=
  641. //----------------------------------------------------------------------------------------
  642.  
  643. template <int tCapacity>
  644. inline FW_CString& 
  645. FW_TBoundedString<tCapacity>::operator=(const FW_TBoundedString<tCapacity>& string)
  646. {
  647.     if (&string != this)
  648.         ReplaceAll(string);
  649.     return *this;
  650. }
  651.  
  652. //----------------------------------------------------------------------------------------
  653. //    FW_TBoundedString<tCapacity>::operator=
  654. //----------------------------------------------------------------------------------------
  655.  
  656. template <int tCapacity>
  657. inline FW_CString& 
  658. FW_TBoundedString<tCapacity>::operator=(const FW_CString& string)
  659. {
  660.     ReplaceAll(string);
  661.     return *this;
  662. }
  663.  
  664. //----------------------------------------------------------------------------------------
  665. //    FW_TBoundedString<tCapacity>::operator=
  666. //----------------------------------------------------------------------------------------
  667.  
  668. template <int tCapacity>
  669. inline FW_CString& 
  670. FW_TBoundedString<tCapacity>::operator=(const FW_Char* string)
  671. {
  672.     ReplaceAll(string, FW_StringLength(string));
  673.     return *this;
  674. }
  675.  
  676. //========================================================================================
  677. //    CLASS FW_CDynamicString
  678. //========================================================================================
  679.  
  680. //----------------------------------------------------------------------------------------
  681. //    FW_CDynamicString::operator=
  682. //----------------------------------------------------------------------------------------
  683.  
  684. inline FW_CString& 
  685. FW_CDynamicString::operator=(const FW_CDynamicString& string)
  686. {
  687.     if (&string != this)
  688.         ReplaceAll(string);
  689.     return *this;
  690. }
  691.  
  692. //----------------------------------------------------------------------------------------
  693. //    FW_CDynamicString::operator=
  694. //----------------------------------------------------------------------------------------
  695.  
  696. inline FW_CString& 
  697. FW_CDynamicString::operator=(const FW_CString& string)
  698. {
  699.     ReplaceAll(string);
  700.     return *this;
  701. }
  702.  
  703. //----------------------------------------------------------------------------------------
  704. //    FW_CDynamicString::operator=
  705. //----------------------------------------------------------------------------------------
  706.  
  707. inline FW_CString& 
  708. FW_CDynamicString::operator=(const FW_Char* string)
  709. {
  710.     ReplaceAll(string, FW_StringLength(string));
  711.     return *this;
  712. }
  713.  
  714. //----------------------------------------------------------------------------------------
  715. //    FW_CDynamicString::AllocateRepresentation
  716. //----------------------------------------------------------------------------------------
  717.  
  718. inline void FW_CDynamicString::AllocateRepresentation(FW_ByteCount capacity)
  719. {
  720.     fRepresentation = new FW_Byte[capacity+sizeof(FW_Char)];
  721.     fCapacity=capacity;
  722.     SetLength(0,0);
  723. }
  724.  
  725. #endif
  726.